<?php

declare (strict_types = 1);

namespace app\model;

use think\facade\Config;

/**
 * 标签文章表
 * @mixin \think\Model
 */
class TagArticle extends Base
{
    protected $pk = "tartid";

    protected $schema = [
        "tartid" => "int",  // 
        "infoid" => "int",  // 文章id
        "cid" => "int",  // 栏目id
        "tagid" => "int",  // 标签id
    ];

    protected $autoWriteTimestamp = false;    

    public function article()
    {
        return $this->belongsTo('Article', 'infoid')->bind(['id','title','titlepic','summary','hits','create_time','username']);
    }

    public function category()
    {
        return $this->belongsTo('Category', 'cid')->bind(['category_url'=>'url','category_name'=>'name']);
    }

    public static function queryList($tagid)
    {
        return self::with(['article','category'])->where('tagid', $tagid)->order('infoid DESC')->paginate();
    }

}
